// 节流
function throttle(fn:()=>{},delay:number) {
    let timer:any;
    return function(){
        if(timer){return;}
        timer = setTimeout(()=>{
            fn();
            timer = null
        },delay)
    }
}

// 防抖
function debounce(fn:()=>{},delay:number){
    let timer:any;
    return function(){
        clearTimeout(timer);
        timer = setTimeout(()=>{
            fn()
        },delay)
    }
}